﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using socialnetworkApp.Domain;
using socialnetworkApp.Domain.Dto.Input;
using socialnetworkApp.Domain.Dto.Output;
using socialnetworkApp.Service.JobService;

namespace socialnetworkApp.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class JobController : ControllerBase
    {
        private readonly IJobService _jobService;
        public JobController(IJobService jobService) { 
         
            _jobService = jobService;
        }

        /// <summary>
        /// 账号密码登录系统
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("login")]
        public async Task<ResponseResult<LoginInfoOutput>> Login([FromBody] loginInfoDto request)
        {


           return await _jobService.UserLogin(request);
        }
        /// <summary>
        /// 招聘系统用邮箱和上传验证码验证登录（注册）
        /// </summary>
        /// <param name="userLoginInput"></param>
        /// <returns></returns>
        [HttpPost("register")]
      public  async Task<ResponseResult<LoginInfoOutput>> UserValidateCodeLogin(UserLoginInput userLoginInput) 
        {
        
            return await _jobService.UserValidateCodeLogin(userLoginInput);
        }
        /// <summary>
        /// 根据用户id获取信息
        /// </summary>
        /// <returns></returns>
        [HttpGet("jobUserInfo")]
        [Authorize]
        public async Task<ResponseResult<JobUserInfoOutput>> GetJobUserInfo() {

            var uid = User.GetUserId();
            //var uid = "2f7c8941-16a1-44a0-8504-aa40cad53faf";
            return await _jobService.GetJobUserInfo(uid);
        }
        [HttpPost("getJobListingList")]
        public async Task<ResponseResult<JobListingOutput>> GetJobListingList([FromBody] SearchJobListInput searchJobListInput)
        {
          return await  _jobService.GetJobListingList(searchJobListInput);
        
        }
    }
}
